<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/adminHead.jsp" %>
	<script type="text/javascript" src="${jsUrl}/SmartEditorBasic2/js/HuskyEZCreator.js" charset="utf-8"></script>

  <TR>
    <TD height="%" valign="top">
      <TABLE width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <TBODY>
        <TR>
          <TD width="186" height="%" align="right" valign="top"><!-- Left Menu table 시작 --------------------------------> 
                        
            <TABLE width="176" height="100%" border="0" cellspacing="0" 
            cellpadding="0">
              <TBODY>
              <TR>
                <TD height="53"><IMG 
              src="${imgUrl}/left_top_title.gif"></TD></TR>
              <TR>
                <TD height="%" background="${imgUrl}/left_bg.gif" valign="top" 
                style="padding: 5px 0px 0px 5px;"><LINK href="${cssUrl}/admin.css" 
                  rel="stylesheet" type="text/css"> <!-- Menu table 끝 * css사용 해당메뉴의 페이지일때는  class="leftmenu_b", 해당 메뉴페이지가 아닐경우  class="leftmenu"로 사용--------------------------------> 
                  <TABLE width="150" style="margin-top: 10px;" border="0" 
                  cellspacing="0" cellpadding="0">
                    <TBODY>
					<c:forEach var = "menu" items="${menuList}">					
						<tr>
							<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/>
								<a class="leftmenu" href="javascript:goAdminBoardListMain(<c:out value="${menu.menuIndex}" />, <c:out value="${menu.menuType}" />)"><c:out value="${menu.menuName}" /></a>
							</td>
						</tr>				
					</c:forEach>
					<tr>
						<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/><a class="leftmenu" href="javascript:goAdminMenuList();">&nbsp;메뉴관리</a></td>
					</tr>
						</TBODY></TABLE></TD></TR></TBODY></TABLE><!-- Left Menu table 끝 --------------------------------> 
                    </TD>
          <TD width="%" align="right" valign="top" style="padding: 20px 10px 0px 0px;">
            <TABLE width="97%" border="0" cellspacing="0" cellpadding="0">
              <TBODY>
              <TR>
                <TD align="left" class="admin_title" background="${imgUrl}/title_bg.gif" 
                valign="middle"><IMG align="absmiddle" src="${imgUrl}/title_icon.gif"><c:out value="${menu.menuName}" /></TD></TR>
              <TR>
                <TD height="20">&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE width="100%" border="0" cellspacing="0" 
cellpadding="0">
                    <TBODY>
                    <TR>
                      <TD><!--리스트 테이블 시작-->                       
                      <form name="theForm" id="theForm" method="post" enctype="multipart/form-data">
                        <TABLE width="100%" bgcolor="#d9d9d9" border="0" cellspacing="1" cellpadding="0">
                          <TBODY>
                          <TR>
                            <TD height="1" bgcolor="#3f8bc9" 
colspan="2"></TD></TR>
                          <TR>
                            <TD width="10%" align="center" class="top_blue3" 
                            bgcolor="#eff3fa">제목</TD>
                            <TD align="left" class="top_blue3" style="padding-left: 10px;" 
                            bgcolor="#eff3fa"><INPUT name="title" class="inputText" style="width: 95%;" type="text" id="title" value="${boardView.title}"></TD></TR>
                         <%--  <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">이미지</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                              <input type='file' size='70' name='imgAttachmentFile' id="imgAttchmentFile" value="<c:out value="${boardView.imgAttachmentFile }"/>"></TD></TR> --%>
                          <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">첨부파일</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                              <input type='file' size='70' name='attachmentFile' id="attchmentFile" value="<c:out value="${boardView.attachmentFile }"/>"></TD>
                          <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">구매포인트</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                              <input type='text' size='70' onKeyUp="isNum(this);" class="inputText" name="usePoint" id="usePoint" value="${boardView.usePoint}"></TD></TR>
                          <!-- <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">누적포인트</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                              <input type='text' size='70' class="inputText" ></TD></TR> -->
                          <TR>
                          <TD align="center" class="bold" bgcolor="#ffffff">정보제공자 <span id="add" onclick="addTr()" style="cursor:hand;">+</span></TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" bgcolor="#ffffff">
                            <table width="100%" id="provider">
                            <c:choose>
                            	<c:when test="${!empty provider}">
                            		<c:forEach var="result" items="${provider}" varStatus="status">
		                            <tr>
		                            	<td width="5%" class="bold">이름</td>
		                            	<td width="90%">
			                            	<INPUT name="providerName[<c:out value='${status.count-1}' />]" class="inputText" style="width: 15%;" type="text" value="<c:out value='${result.providerName}' />">
		                             	</td>
		                             </tr>
		                             <tr>
		                             	<td width="5%" class="bold">주소</td>
		                             	<td width="90%"><INPUT name="providerAddress[<c:out value='${status.count-1}' />]" class="inputText" style="width: 75%;" type="text" value="<c:out value='${result.providerAddress}' />"></td>
		                             </tr>
		                             </c:forEach>
	                             </c:when>
	                             <c:otherwise>
		                             <tr>
		                            	<td width="5%" class="bold">이름</td>
		                            	<td width="90%">
			                            	<INPUT name="providerName[0]" class="inputText" style="width: 15%;" type="text">
		                             	</td>
		                             </tr>
		                             <tr>
		                             	<td width="5%" class="bold">주소</td>
		                             	<td width="90%"><INPUT name="providerAddress[0]" class="inputText" style="width: 75%;" type="text"></td>
		                             </tr>
	                             </c:otherwise>
	                         </c:choose>
                             </table>
                             </TD>
                          </TR>
                          <TR>
                          	<TD style="padding: 10px;" bgcolor="#ffffff" colspan="2">
                          		<TEXTAREA name="preContents" class="input1" id="preContents" style="width: 95%; height: 150px; display:none;">${boardView.preContents}</TEXTAREA>
	                             <SCRIPT type="text/javascript">
	                                     var oEditors = [];
	                                     nhn.husky.EZCreator.createInIFrame({
	                                         oAppRef      : oEditors,
	                                         elPlaceHolder: "preContents",
	                                         sSkinURI     : "${jsUrl}/SmartEditorBasic2/SEditorSkinEditorOnly2.html",
	                                         fCreator     : "createSEditorInIFrame"
	                                     });
	                                     insertIMG = function (getId, fname) {
	                                         var sHTML = "<img src='" + imagepath + "/" + fname + "' style='cursor:hand;' border='0'>";
	                                         oEditors.getById[getId].exec("PASTE_HTML", [sHTML]);
	                                     };
	                             </SCRIPT>
                          	</TD>
                          </TR>
                          <TR>
                            <TD style="padding: 10px;" bgcolor="#ffffff" colspan="2">
                            <TEXTAREA name="contents" class="input1" id="contents" style="width: 95%; height: 250px; display:none;">${boardView.contents}</TEXTAREA>
                             <SCRIPT type="text/javascript">                                     
                                     nhn.husky.EZCreator.createInIFrame({
                                         oAppRef      : oEditors,
                                         elPlaceHolder: "contents",
                                         sSkinURI     : "${jsUrl}/SmartEditorBasic2/SEditorSkinEditorOnly.html",
                                         fCreator     : "createSEditorInIFrame"
                                     });
                                     insertIMG = function (getId, fname) {
                                         var sHTML = "<img src='" + imagepath + "/" + fname + "' style='cursor:hand;' border='0'>";
                                         oEditors.getById[getId].exec("PASTE_HTML", [sHTML]);
                                     };
                             </SCRIPT>
                            <input type="hidden" name="menuIndex" id="menuIndex" value="${menu.menuIndex}">
                            <input type="hidden" name="menuType" id="menuType" value="${menu.menuType}">
                            <input type="hidden" name="textID" id="textID" value="${boardView.textID}">
                            <input type="hidden" name="mode" id="mode" value="${mode}">
                        </TD></TR></TBODY></TABLE></form><!--리스트 테이블 끝-->               
                            </TD></TR>
                    <TR>
                      <TD height="35" align="right">
                      	<img src="${imgUrl}/btn_submit.gif" border="0" hspace="3" onClick="goRegist();" style="cursor:hand;">
                      	<img src="${imgUrl}/btn_list.gif" border="0" onClick="goBoardList();" style="cursor:hand;">
                      </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<form style="display:none;" id="frm" name="frm" method="post">
	<input type="hidden" name="msg" id="msg" value="${msg}">
</form>
<script type="text/javascript">
var msg = $("#msg").val();
if(msg != '') {
	alert(msg);
	goBoardList();
}
function goAdminBoardListMain(type, menuType) {
	// type = 1 공지사항
		// type = 2 최신판례
		// type = 3 최신법령
		// type = 4 A항목
		// type = 5 B항목
		// type = 6 C항목
		// type = 7 D항목
		// type = 8 E항목
		// type = 9 F항목
		// type = 10 G항목
		// type = 11 H항목
		$("#menuIndex").val(type);
		var url;
		
		if (menuType == 0) {
			url = "/admin/adminBoardMain";
		} else {
			url = "/admin/adminBoard2Main";
		}
					
		$("#theForm").attr("action", url);
		$("#theForm").submit();
		
  }
  
  function goBoardList() {
	  var menuIndex = $("#menuIndex").val();
	  var menuType = $("#menuType").val();
	  goAdminBoardListMain(menuIndex, menuType);
  }
  
  function goRegist() {
	var title = $("#title").val();
	if(title == '') {
		alert('제목을 입력하세요.');
		$('#title').focus();
		return;
	}
	oEditors.getById["preContents"].exec("UPDATE_IR_FIELD", []);	
	var preContent = $("#preContents").val();
	alert(preContent);
	if(preContent == '') {
		alert("미리보기 내용을 입력하세요.");
		$('#preContent').focus();
		return;
	}
	
	oEditors.getById["contents"].exec("UPDATE_IR_FIELD", []);
	var content = $("#contents").val();
	if(content == '') {
		alert("내용을 입력하세요.");
		$('#contents').focus();
		return;
	}
	
	var usePoint = $("#usePoint").val();
	if(usePoint == '') {
		alert("구매포인트 입력하세요.");
		$('#usePoint').focus();
		return;
	}
	
	$("#theForm").attr("action", "/admin/adminRegistBoard");
	$("#theForm").submit();
  }
  function isNum(obj){ 
	  var val=obj.value;

		re=/[^0-9]/gi;
		if(re.test(val)) {
			alert('숫자만 입력가능합니다.');
			obj.value = "";
			obj.focus();
			return;
		}
	}
  var i = 0;
  function addTr() {
	  	i++;
		$("#provider").append('<tr><td width="5%" class="bold">이름</td>'+
						 	  '    <td width="90%">'+
						 	  '       <input name="providerName['+i+']" class="inputText" style="width:15%"; type="text">' +
						 	  '    </td>'+
						 	  '</tr>'+
						 	  '<tr><td width="5%" class="bold">주소</td>'+
						 	  '    <td width="90%">'+
						 	  '       <input name="providerAddress['+i+']" class="inputText" style="width:75%"; type="text">' +
						 	  '    </td>'+
						 	  '</tr>'						 	  
						); 
	}
  var goAdminMenuList = function(){
		location.replace("/admin/adminMenuMain");
	};
</script>

</BODY></HTML>
